﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BLL;
using Model;
using Web.Helper;

namespace Web.Areas.Manager.Controllers
{
    [UserAuthorize]
    public class M_ReceiveFormController : Controller
    {
       M_ReceiveForm_BLL _M_ReceiveForm_BLL = new M_ReceiveForm_BLL();

          public virtual ActionResult Index(int? pageIndex, string keyword)
        {
            var model = _M_ReceiveForm_BLL.Get();
            if (!string.IsNullOrEmpty(keyword))
            {
              //  model = model.Where(a => a.UserName.Contains(keyword));
            }
            return View(model.ToPagedList(pageIndex));
        }


        public virtual ActionResult Details(Guid Id)
        {
            var item = _M_ReceiveForm_BLL.Get(Id);
            return View(item);
        }
     
        public virtual ActionResult Edit(Guid? Id)
        {
            var item = _M_ReceiveForm_BLL.Get(Id);
            return View(item);
        }

        [HttpPost]
         public virtual ActionResult Edit(Guid? Id, M_ReceiveForm collection)
        {
            if (!ModelState.IsValid)
            {
                return View(collection);
            }
            _M_ReceiveForm_BLL.Save(Id, ref collection);
            return RedirectToAction("Index",MyrouteValues.Get());
        }

        [HttpDelete]
        public virtual ActionResult Delete(Guid Id)
        { 
            _M_ReceiveForm_BLL.Delete(Id);
            return RedirectToAction("Index",MyrouteValues.Get());
        }
    }
}
